package ar.edu.unlp.info.tesis.domain;

import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonSubTypes;
import org.codehaus.jackson.annotate.JsonTypeInfo;

/**
 * El actor puede representar a un agente o a un grupo.
 * 
 * https://github.com/adlnet/xAPI-Spec/blob/master/xAPI.md#actor
 * 
 * 
 */
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "TYPE", discriminatorType = DiscriminatorType.STRING)
@Table(name = "Actor")
@DiscriminatorValue(value = "ACTOR")

@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "objectType")
@JsonSubTypes({ @JsonSubTypes.Type(value = Agent.class, name = "AGENT"),
@JsonSubTypes.Type(value = Group.class, name = "GROUP"), })

public abstract class Actor extends Entidad implements StatementObject {

	private long dataBaseId;
	
	private String id;

	private String name;
	
	@Id
	@GeneratedValue
	@JsonIgnore
	@Column(name = "DATABASEID")
	public long getDataBaseId() {
		return dataBaseId;
	}
	
	public void setDataBaseId(long dataBaseId) {
		this.dataBaseId = dataBaseId;
	}

	@Column(name = "ID", unique = true, nullable = false)
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@Column(name = "NAME", nullable = false)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	@Override
	@Transient
	public String getLabelFormat() {
		return this.getName();
	}
}
